﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using EShop.Model;
using EShop.DAL;

namespace EShop.BLL
{
    public class StockInBLL
    {
        /// <summary>
        /// 添加入库信息
        /// JF
        /// </summary>
        /// <param name="oStockIn"></param>
        /// <returns></returns>
        public bool AppendStockIn(StockIn oStockIn)
        {
            return new StockInDAL().AppendStockIn(oStockIn);
        }

        /// <summary>
        /// 根据Barcode查询该商品的信息。
        /// JF
        /// </summary>
        /// <param name="strBarcode"></param>
        /// <returns></returns>
        public MerchandiseBasicInfo GetMerchandiseInfo(string strBarcode)
        {
            MerchandiseBasicInfo oMerchandiseBasicInfo = new MerchandiseBasicInfo();
            StockInDAL oStockInDAL = new StockInDAL();
            DataTable dt = oStockInDAL.GetMerchandiseInfo(strBarcode);
            int index = dt.Rows.Count;
            if (index <= 0) return null;
            else
            {
                oMerchandiseBasicInfo.Barcode = dt.Rows[0]["Barcode"].ToString();
                oMerchandiseBasicInfo.MerchandiseClassName = dt.Rows[0]["MerchandiseClassName"].ToString();
                oMerchandiseBasicInfo.MerchandiseName = dt.Rows[0]["MerchandiseName"].ToString();
                oMerchandiseBasicInfo.MerchandiseUnitID = (int)dt.Rows[0]["MerchandiseUnitID"];
                oMerchandiseBasicInfo.MerchandiseUnitName = dt.Rows[0]["UnitName"].ToString();
                oMerchandiseBasicInfo.MerchandiseResume = dt.Rows[0]["MerchandiseResume"].ToString();
                oMerchandiseBasicInfo.MerchandiseRemark = dt.Rows[0]["MerchandiseRemark"].ToString();
                oMerchandiseBasicInfo.IsAlert = (bool)dt.Rows[0]["IsAlert"];
                strBarcode = dt.Rows[0]["AlertNum"].ToString();
                oMerchandiseBasicInfo.AlertNum = (int)dt.Rows[0]["AlertNum"];
                oMerchandiseBasicInfo.HasOverTime = (bool)dt.Rows[0]["HasOverTime"];
                return oMerchandiseBasicInfo;
            }
        }

        /// <summary>
        /// 取得库存数量,上架数量
        /// </summary>
        /// <returns></returns>
        public DataTable GetStockExamineList()
        {
            return new StockInDAL().GetStockExamineList();
        }

        /// <summary>
        /// 取得指定商品的库存数量,上架数量
        /// </summary>
        /// <param name="strBarCode"></param>
        /// <returns></returns>
        public DataTable GetStockExamineList(string strBarCode)
        {
            return new StockInDAL().GetStockExamineList(strBarCode);
        }

    }
}
